<?php
require 'inc_security.php';
                       
$list = new dataGrid('reg_id',30);
$list->add('', 'Thông tin người đặt', 'string');
$list->add('', 'Thông tin sản phẩm', 'string');
$list->add('reg_user_id','Người bán','int',0,0);
$list->add('','Đã bán','string');
$list->add('','Delete','delete');


$db_count = new db_count('SELECT count(*) as count 
                            FROM '.$bg_table.'
                            WHERE 1 '.$list->sqlSearch().'
                            ');
$total = $db_count->total;unset($db_count);

$db_listing = new db_query('SELECT * 
                            FROM '.$bg_table.'
                            WHERE 1 '.$list->sqlSearch().'
                            ORDER BY '.$list->sqlSort().' reg_date DESC
                            '.$list->limit($total));
$total_row = mysql_num_rows($db_listing->result);


?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="vi" lang="vi" xmlns:og="http://ogp.me/ns#" xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?=$load_header?>
</head>
<body>
<div class="module_header bold fix"><?=$module_name?></div>
<div id="wrapper">
    <?=$list->showHeader($total_row)?>
    <?php
    $i = 0; 
    ?>
    <?php while($row = mysql_fetch_assoc($db_listing->result)){
        $i++;
        $db_pro = new db_query('SELECT pro_id,pro_name FROM products WHERE pro_id = '.$row['reg_product_id']);
        $pro = mysql_fetch_assoc($db_pro->result);
        $user_name = 'Trực tiếp';
        if($row['reg_user_id'] != 0) {
            $db_user = new db_query('SELECT use_id,use_name FROM users WHERE use_id = '.$row['reg_user_id']);
            $user = mysql_fetch_assoc($db_user->result);
            $user_name = $user['use_name'];
        }
    ?>
    <?=$list->start_tr($i,$row['reg_id'])?>
    <td>
        <div class="row">
            <div class="span1">Tên: </div>
            <div class="span3"><?=$row['reg_name']?></div>
        </div>
        <div class="row">
            <div class="span1">Số ĐT: </div>
            <div class="span3"><?=$row['reg_phone']?></div>
        </div>
        <div class="row">
            <div class="span1">Email: </div>
            <div class="span3"><?=$row['reg_email']?></div>
        </div>
    </td>
    <td>
        <div class="row">
            <label>Tên SP: <?=$pro['pro_name']?></label>
        </div>
        <div class="row">
            <label>Thời hạn: <?=$arr_term[$row['reg_term']]?></label>
        </div>
        <div class="row">
            <label>Khu vực: <?=$arr_regison[$row['reg_region']]?></label>
        </div>
    </td>
    <td>
        <label>Đăng ký qua: <?=$user_name?></label>
        <label>Ngày đăng ký : <?=date('d/m/Y - h:i a',$row['reg_date'])?></label>
    </td>
    <?=$list->showCheckbox('reg_active',$row['reg_active'],$row[$id_field])?>
    <?=$list->showDelete($row[$id_field])?>
    <?=$list->end_tr()?>
    <?}?>
    <?=$list->showFooter()?>
</div>
</body>
</html>